package model;

import utils.Point3D;

public abstract class BaseLinkModel extends BaseModel
{
	public RoomModel FirstRoom;
	public RoomModel SecondRoom;
	
	public Point3D AnchoragePoint;
	private double length;
	
	public BaseLinkModel(int ID, RoomModel firstRoom, RoomModel secondRoom, Point3D anchoragePoint)
	{
		super(ID);
		this.FirstRoom = firstRoom;
		this.SecondRoom = secondRoom;
		this.AnchoragePoint = anchoragePoint;
		
		double xx1 = (firstRoom.position.x() - anchoragePoint.x()) * (firstRoom.position.x() - anchoragePoint.x());
		double yy1 = (firstRoom.position.y() - anchoragePoint.y()) * (firstRoom.position.y() - anchoragePoint.y());
		double xx2 = (secondRoom.position.x() - anchoragePoint.x()) * (secondRoom.position.x() - anchoragePoint.x());
		double yy2 = (secondRoom.position.y() - anchoragePoint.y()) * (secondRoom.position.y() - anchoragePoint.y());
	
		this.setLength(Math.sqrt(xx1 + yy1) + Math.sqrt(xx2 + yy2));
	}

	public double getLength() {
		return length;
	}

	public void setLength(double length) {
		this.length = length;
	}
}
